package com.lvmama.pangolin.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lvmama.pangolin.entity.BlackIPConditionVO;
import com.lvmama.pangolin.entity.IPListConditionVO;
import com.lvmama.pangolin.entity.IP;
import com.lvmama.pangolin.entity.IpBlack;
import com.lvmama.pangolin.mybatis.mapper.IPMapper;
import com.lvmama.pangolin.service.IPService;
@Transactional
@Service
public class IPServiceImpl implements IPService{
	/**   
	* @Title: IPServiceImpl.java  
	* @Description: TODO(用一句话描述该文件做什么) 
	* @author ZhouTianQi   
	* @date 2017年1月19日 上午10:39:39 
	* @version V1.0   
	*/
	@Autowired
	private IPMapper ipMapper;

	@Override
	public PageInfo<IP> getIPList(IPListConditionVO iPListConditionVO) throws Exception {
		 PageHelper.startPage(iPListConditionVO.getPage(), iPListConditionVO.getPageSize());
		 List<IP> ipVoList = ipMapper.getIPList(iPListConditionVO);
		 PageInfo<IP> page = new PageInfo<IP>(ipVoList);
	     return page;
	}

	@Override
	public int insertBlackIP(String ip,String available,String remark) throws Exception {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("syscode", "1111");
		param.put("ip", ip);
		param.put("available", available);
		param.put("remark", remark);
		return ipMapper.insertBlackIP(param);
	}

	@Override
	public PageInfo<IpBlack> getBlackIPList(BlackIPConditionVO blackIPConditionVO) throws Exception {
		 PageHelper.startPage(blackIPConditionVO.getPage(), blackIPConditionVO.getPageSize());
		 List<IpBlack> ipBlackList = ipMapper.getBlackIPList(blackIPConditionVO);
		 PageInfo<IpBlack> page = new PageInfo<IpBlack>(ipBlackList);
	     return page;
	}

	@Override
	public int insertProxyIP(IP ip) throws Exception
	{
		return ipMapper.insertProxyIP(ip);
	}

	@Override
	public int insertProxyIPBatch(List<IP> list) throws Exception
	{
		return ipMapper.insertProxyIPBatch(list);
	}

	@Override
	public List<IP> queryIPOrderByid(Map<String,Object> param) throws Exception
	{
		return ipMapper.queryIPOrderByid(param);
	}
	
	public int updateIPStatusByid(IP ip)
	{
		return ipMapper.updateIPStatusByid(ip);
	}
	public int deleteUnvalidIP(IP ip)
	{
		return ipMapper.deleteUnvalidIP(ip);
	}
	
	
	
	
}
